package exception;

import java.io.FileNotFoundException;

/**
 * 异常的抛出
 */
public class ThrowDemo {
    public static void main(String[] args) {
        /*
        Student zs = new Student();
        zs.setAge(10);
        System.out.println(zs.getAge());
         */

        //自己抛出异常
        /*
        Student zs = new Student();
        try {
            zs.setAge(1000);
            System.out.println(zs.getAge());
        }catch (Exception e){
            System.out.println("年龄不合法");
        }
         */

        Student zs = new Student();
        try {
            zs.setAge(10);
        } catch (IllegalAgeException e) {
            System.out.println("发现异常,并解决了...");;
        }
        System.out.println(zs.getAge());
    }
}
